//区间修改＋区间查询（带懒标记）求区间和
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+10;

int arr[N];

struct Node
{
    int l,r,sum,add;
}tr[4*N];
void pushup(int u)
{
    tr[u].sum = tr[u<<1].sum + tr[u<<1|1].sum;
}
void build(int u,int l,int r)
{
    // 对 [l,r] 区间建立线段树,当前根的编号为 u
    if(l==r) 
    {
        tr[u] = {l,r,arr[r],0};
        return;
    }
    else 
    {
        tr[u]={l,r};
        int mid = l + r >> 1;
        build(u<<1,l,mid),build(u<<1|1,mid+ 1,r);
        pushup(u);
    }
}



void pushdown(int u)
{
    auto &root = tr[u],&left = tr[u<<1],&right = tr[u<<1|1];
    
    if(root.add)
    {
        left.add += root.add,left.sum += (left.r-left.l+1)*root.add;
        right.add+= root.add,right.sum+=(right.r-right.l+1)*root.add;
        root.add = 0;
    }
}


void modify(int u,int l,int r,int d)
{
    if(tr[u].l>=l&&tr[u].r<=r)
    {
        tr[u].sum += (tr[u].r - tr[u].l + 1)*d;
        tr[u].add += d;
        return;
    }
    
    else
    {
        pushdown(u);
        int mid = tr[u].l + tr[u].r >> 1;
        if(l<=mid)
        {
            modify(u<<1,l,r,d);
        }
        if(mid<r)
        {
            modify(u<<1|1,l,r,d);
        }
        pushup(u);
    }
}

int quary(int u,int l,int r)
{
    if(tr[u].l>=l&&tr[u].r<=r) return tr[u].sum;
    else
    {
        pushdown(u);
        int mid = tr[u].l + tr[u].r >> 1;
        int sum = 0;
        if(l<=mid) sum = quary(u<<1,l,r);
        // 如果左儿子代表的区间 [l, mid] 与询问区间有交集, 则递归查询左儿子
        if(mid<r) sum += quary(u<<1|1,l,r);
        // 如果右儿子代表的区间 [m + 1, r] 与询问区间有交集, 则递归查询右儿子
        return sum;
    }
   
}

signed main()
{
    int n;
    cin >> n;
    int q;
    cin >> q;
    
    for(int i = 1;i<=n;i++) cin >> arr[i];
    
    build(1,1,n);
    while(q--)
    {
        char s;
        cin >> s;
        if(s=='Q')
        {
            int l,r;
            cin >> l >> r;
            cout<<quary(1,l,r)<<endl;
        }
        else 
        {
            int l,r,d;
            cin >> l>> r >> d;
            modify(1,l,r,d);
        }
    }
    return 0;
}
